unit uWindow;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ToolWin, Grids, DBGridEh, Menus, ImageTools;

type
  TfWindow = class(TForm)
    GroupBox1: TGroupBox;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    DBGridEh1: TDBGridEh;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ToolButton1Click(Sender: TObject);
    procedure DBGridEh1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
    procedure ToolButton2Click(Sender: TObject);
    procedure DBGridEh1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fWindow: TfWindow;

implementation

uses uDBData, uAddWindow;

{$R *.dfm}

procedure TfWindow.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  FormStyle := fsNormal;
  ShowWindow(Handle, SW_HIDE);
end;

procedure TfWindow.ToolButton1Click(Sender: TObject);
begin
  fAddWindow.ShowModal();
end;

procedure TfWindow.DBGridEh1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
begin
  if(Column.Index = 1) then
  begin
    (Sender as TDBGridEh).Canvas.Draw(Rect.Left, Rect.Top, HImageTools.GetBitmap(fDBData.dWindow, 'WindowImage'));
  end;
end;

procedure TfWindow.ToolButton2Click(Sender: TObject);
begin
  fDBData.DeleteRecord(fDBData.dWindow);
end;

procedure TfWindow.DBGridEh1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then (Sender as TDBGridEh).DataSource.DataSet.Post;
end;

end.
